package com.example.demo.controller;

import com.example.demo.model.Result;
import com.example.demo.service.ProductService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
@AllArgsConstructor
public class ProductController {
    private ProductService productService;

    @GetMapping
    public Result getProduct(@RequestParam(defaultValue = "1") Integer current,
                             @RequestParam(defaultValue = "10") Integer pageSize){
        return productService.getPageData(current,pageSize);

    }

    @GetMapping("/{id}")
    public void getP(@PathVariable("id") Integer id){
        System.out.println("----------------------------");
        System.out.println(id);
//        return null;

    }

    @GetMapping("/d/{goodId}")
    public Result getGood(@PathVariable("goodId") Integer goodId) {
        return productService.getgoodById(goodId);
    }
}